Added weighted extra ice trap selection and rework extra traps system#6682
Open
JD-Spencer wants to merge 5 commits into
Open
Added weighted extra ice trap selection and rework extra traps system#6682JD-Spencer wants to merge 5 commits into
JD-Spencer wants to merge 5 commits into
Conversation
This commit replaces the previous vector-based trap enabling system with a new weighted trap selection mechanism. The `selectWeightedTrap` function is introduced to calculate weights for each trap type based on user-defined settings and select traps using a random weighted approach. The `getEnabledAddTraps` function is removed, and `RollRandomTrap` is updated to use the new weighted system. A fallback ensures that an "Ice Trap" is selected if no valid trap is chosen. A new configuration option, `ExtraTraps.WeightedTraps`, is added to toggle the weighted system. The UI is updated to include sliders for setting individual trap weights (0-100) and hides checkboxes for traps when the weighted system is enabled. Additional logging is added to trace the trap selection process, including weights and the selected trap.
Deferred traps and status traps (slow movement) now get placed into a time queue to be executed after x many game ticks. This should make it easier to add more traps.
serprex
reviewed
Jun 6, 2026
Comment on lines
+99
to
+102
| if (roll == ADD_TRAP_MAX) // If it failed to pick a trap, fallback to a basic ice trap. | ||
| { | ||
| roll = ADD_ICE_TRAP; | ||
| } |
Member
There was a problem hiding this comment.
might as well just return ADD_ICE_TRAP in selectWeightedTrap
serprex
approved these changes
Jun 6, 2026
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
Pepper0ni
approved these changes
Jun 21, 2026
| roll = ShipUtils::RandomElement(getEnabledAddTraps(), &state); | ||
| switch (roll) { | ||
| case ADD_ICE_TRAP: | ||
| case ADD_ICE_TRAP: { |
Contributor
There was a problem hiding this comment.
Not a big deal, but why are we adding brackets here?
Author
There was a problem hiding this comment.
When I was originally writing this, the lambdas were in variables, and there were name collisions. I just never removed the braces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extra ice traps currently have an equal chance of occurring regardless of the trap. Added a toggle to the settings to change the weight for the random extra ice trap selection. This way the player can keep more punishing traps enabled with a lower/higher frequency.
Reworked how deferred traps work. Rather than sharing a single timer, each trap can queue its own timer. Should make it easier to add more status effect traps in the future.
Changed the slow down trap to extend the timer if triggered while it is still active.
Build Artifacts